// pages/questions/project.js
const app = getApp();
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      imgPath: app.d.imgPath
    })
    this.getSystemInfo();
    // this.getProCate();
    this.getProList(options.id);
  },

  getSystemInfo: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          height: res.windowHeight,
          width: res.windowHeight
        })
      }
    })
  },

  /*获取产品列表*/
  getProList: function (e) {
    console.log(e);//专业id
    var that = this;
    var sucFunc = function (that, res) {
      console.log(res.data)

      that.setData({
        proList: res.data
      })
    }
    var data = { profession_id: e }
    utils.wxRequest(that, app.d.path, "Profession/subject", data, sucFunc);
    // that.setData({
    //   proList: [
    //     { id: "17", title: "不锈钢饭店厨房油烟净化器", fimg: "http://cdcfsb.hrkjwx.com/static/myadmin/kindeditor/attached/image/20180118/20180118144537_26885.png", count: "56565" },
    //     { id: "18", title: "不锈钢烟罩", fimg: "http://cdcfsb.hrkjwx.com/static/myadmin/kindeditor/attached/image/20180118/20180118144650_85256.jpg", count: "56565" },
    //     { id: "26", title: "油水分离器", fimg: "http://cdcfsb.hrkjwx.com/static/myadmin/kindeditor/attached/image/20180118/20180118145459_55120.jpg", count: "56565" }
    //   ]
    // })

    // wx.request({
    //   url:  'test.php', //仅为示例，并非真实的接口地址
    //   data:  {
    //     x:  '' ,
    //     y:  ''
    //   },
    //   header:  {
    //     'content-type':  'application/json'
    //   },
    //   success:  function (res)  {
    //     console.log(res.data)
    //     that.setData({
    //       proList: res.data.proList
    //     })
    //   }
    // })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})